//
//  TravelTopicDetailsOneTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/15.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "TravelTopicDetailsOneTableViewCell.h"

@interface TravelTopicDetailsOneTableViewCell ()


@property (nonatomic, retain) UILabel *labelD;

@property (nonatomic, retain) UIView *view;
@end


@implementation TravelTopicDetailsOneTableViewCell

-(void)dealloc
{
    [_labelD release];
    [_model release];
    [_view release];
    [super dealloc];
   
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.labelD =[[ UILabel alloc]init];
       // self.labelD.backgroundColor = [UIColor redColor];
        self.labelD.font = [UIFont systemFontOfSize:15 *kWidth];
        self.labelD.numberOfLines = 0;
        
        [self addSubview:self.labelD];
        [_labelD release];
        
    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.labelD.frame = CGRectMake(10 *kWidth, 10 *kHeight, self.frame.size.width - 20 *kWidth, [[self class] heightOfLabel:self.model.DES andTextFont:self.labelD.font andTextWidth:self.frame.size.width - 20 *kWidth]);
    self.labelD.font = [UIFont systemFontOfSize:15 *kWidth];
    self.labelD.textColor =[UIColor colorWithWhite:0.256 alpha:1.000];
//    self.view.frame = CGRectMake(5 *kWidth, self.labelD.frame.size.height + 10 *kHeight, self.frame.size.width - 10 *kWidth, 2*kHeight);
}


+(CGFloat)heightOfLabel:(NSString *)text andTextFont:(UIFont *)font andTextWidth:(CGFloat)width
{
    CGSize size = CGSizeMake(width, MAXFLOAT);
    NSDictionary *dictionary = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dictionary context:nil];
    return frame.size.height;
}
-(void)setModel:(TravelTopicDetailsModel *)model
{
    if (_model != model) {
        [_model release];
        _model  = [model retain];
    }
    
    self.labelD.text = model.DES;
}



/*
 
 
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
